/**
 * Copyright (c) Software Institude of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.model.uml.FundamentalActivities;
// imports:
import org.w3c.dom.Element;

import edu.pku.sei.gefcommon.descriptor.annotation.MethodProperty;
import edu.pku.sei.modeler.model.common.*;
import edu.pku.sei.modeler.model.core.*;
import edu.pku.sei.modeler.model.xml.XMLUtility;

import edu.pku.sei.modeler.model.uml.BasicActivities.ActivityEdge;
import edu.pku.sei.modeler.model.uml.StructuredActivities.Variable;
import edu.pku.sei.modeler.model.uml.StructuredActivities.StructuredActivityNode;

import edu.pku.sei.modeler.model.uml.BasicBehaviors.Behavior;
import edu.pku.sei.modeler.uml.modelHelper.ModelPackage;

/**
 * @generated
 *
 */
public class Activity extends Behavior implements IActivity {
	// attributes
	
	protected boolean isReadOnly;
	
	protected boolean isSingleExecution;
	
	
	
	
	// references
	
	protected MetaTypedList ownedNode;
	
	protected MetaTypedList ownedGroup;
	
	protected MetaTypedList ownedEdge;
	
	protected MetaTypedList ownedMember;
	
	protected MetaTypedList structuredNode;
	
	
	public Activity(){
		this.name = "unnamed activity";
	}
	
	// getters & setters for attributes
	
	@MethodProperty(
			id = "ACTIVITY_ISREADONLY",
			catalog = "Model",
			name = ModelPackage.ACTIVITY_ISREADONLY,
			setter = "setisReadOnly"
			)
	
	public boolean getIsReadOnly() {
		return isReadOnly;
	}
	public void setIsReadOnly(boolean newIsReadOnly) {
		boolean oldisReadOnly = isReadOnly;
		isReadOnly = newIsReadOnly;
		firePropertyChange(ModelPackage.ACTIVITY_ISREADONLY, oldisReadOnly, newIsReadOnly);
	}
	
	@MethodProperty(
			id = "ACTIVITY_ISSINGLEEXECUTION",
			catalog = "Model",
			name = ModelPackage.ACTIVITY_ISSINGLEEXECUTION,
			setter = "setisSingleExecution"
			)
	
	public boolean getIsSingleExecution() {
		return isSingleExecution;
	}
	public void setIsSingleExecution(boolean newIsSingleExecution) {
		boolean oldisSingleExecution = isSingleExecution;
		isSingleExecution = newIsSingleExecution;
		firePropertyChange(ModelPackage.ACTIVITY_ISSINGLEEXECUTION, oldisSingleExecution, newIsSingleExecution);
	}
	
	// getters for references
	
	public MetaTypedList getOwnedNode() {
		if(ownedNode == null) {
			ownedNode = new MetaTypedList(ActivityNode.class, this, ModelPackage.ACTIVITY_OWNEDNODE);
		}
		return ownedNode;
	}
	
	public MetaTypedList getOwnedGroup() {
		if(ownedGroup == null) {
			ownedGroup = new MetaTypedList(ActivityGroup.class, this, ModelPackage.ACTIVITY_OWNEDGROUP);
		}
		return ownedGroup;
	}
	
	public MetaTypedList getOwnedEdge() {
		if(ownedEdge == null) {
			ownedEdge = new MetaTypedList(ActivityEdge.class, this, ModelPackage.ACTIVITY_OWNEDEDGE);
		}
		return ownedEdge;
	}
	
	public MetaTypedList getOwnedMember() {
		if(ownedMember == null) {
			ownedMember = new MetaTypedList(Variable.class, this, ModelPackage.ACTIVITY_OWNEDMEMBER);
		}
		return ownedMember;
	}
	
	public MetaTypedList getStructuredNode() {
		if(structuredNode == null) {
			structuredNode = new MetaTypedList(StructuredActivityNode.class, this, ModelPackage.ACTIVITY_STRUCTUREDNODE);
		}
		return structuredNode;
	}
	
	// save & load
	public void serialize(Element root) {
		super.serialize(root);
		// attributes
		
		XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.ACTIVITY_ISREADONLY, isReadOnly);
		
		XMLUtility.xmlInstance.serializeAttribute(root, ModelPackage.ACTIVITY_ISSINGLEEXECUTION, isSingleExecution);
		
		// references
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.ACTIVITY_OWNEDNODE, ownedNode);		
		
		XMLUtility.xmlInstance.serializeNodes(root, ModelPackage.ACTIVITY_OWNEDGROUP, ownedGroup);
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.ACTIVITY_OWNEDEDGE, ownedEdge);		
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.ACTIVITY_OWNEDMEMBER, ownedMember);		
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.ACTIVITY_STRUCTUREDNODE, structuredNode);		
		
	}
	
	public void deSerialize(Element root) {
		super.deSerialize(root);
		// attributes
		
		isReadOnly = XMLUtility.xmlInstance.deSerializeBoolean(root, ModelPackage.ACTIVITY_ISREADONLY);
		
		isSingleExecution = XMLUtility.xmlInstance.deSerializeBoolean(root, ModelPackage.ACTIVITY_ISSINGLEEXECUTION);
		
		// references
		
		this.getOwnedNode().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.ACTIVITY_OWNEDNODE, this));
		
		this.getOwnedGroup().addAll(XMLUtility.xmlInstance.deSerializeNodes(root, ModelPackage.ACTIVITY_OWNEDGROUP));
		
		this.getOwnedEdge().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.ACTIVITY_OWNEDEDGE, this));
		
		this.getOwnedMember().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.ACTIVITY_OWNEDMEMBER, this));
		
		this.getStructuredNode().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.ACTIVITY_STRUCTUREDNODE, this));
		
	}
	
	public void dynamicSet(String featureID, Object value) {
		if(featureID == null || "".equals(featureID)) {
			return;
		}
		// attributes
		
		// references
		
		else if(ModelPackage.ACTIVITY_OWNEDNODE.equals(featureID)) {
			getOwnedNode().add(value);
		}
		
		else if(ModelPackage.ACTIVITY_OWNEDEDGE.equals(featureID)) {
			getOwnedEdge().add(value);
		}
		
		else if(ModelPackage.ACTIVITY_OWNEDMEMBER.equals(featureID)) {
			getOwnedMember().add(value);
		}
		
		else if(ModelPackage.ACTIVITY_STRUCTUREDNODE.equals(featureID)) {
			getStructuredNode().add(value);
		}
		
		else
			super.dynamicSet(featureID, value);
	}
}
 
 
 
 
 